package com.mfz.common.definition.symbol

/**
 * 标志字段
 */

abstract class Symbol {
	abstract val id: Int
	abstract val name: String

	override fun toString(): String {
		return name
	}

	override fun equals(other: Any?): Boolean {
		if (other !is Symbol) {
			return false
		}

		return this.id == other.id || this.name == other.name
	}

	override fun hashCode(): Int {
		return id
	}
}

class SymbolAlreadyExistsException(symbol: Symbol) : RuntimeException("标志已经存在。不可以再次增加此标志, id:${symbol.id}.name:${symbol.name}")


internal fun checkSymbolExists(symbols: ArrayList<out Symbol>, symbol: Symbol): Boolean {
	for (ele in symbols) if (ele == symbol) return true
	return false
}
